import React from "react";
import { 
  Navigate,
  useRoutes
} from "react-router-dom";


// import MyMine from "@/pages/mine";

// import MyDiscover from "@/pages/discover";
// import DisRecommend from "@/pages/discover/cpns/recommend";
// import DisRanking from "@/pages/discover/cpns/ranking";
// import DisSongs from "@/pages/discover/cpns/songs";
// import DisDjradio from "@/pages/discover/cpns/djradio";
// import DisArtist from "@/pages/discover/cpns/artist";
// import DisAlbum from "@/pages/discover/cpns/album";
// import DisPlayer from "@/pages/player";

// import MyFriend from "@/pages/friend";

//路由懒加载：打包之后build/static/js会分模块，当用户主动触发事件才执行js。
const MyMine = React.lazy(() => import("@/pages/mine"));
const MyDiscover = React.lazy(_ => import("@/pages/discover"));
const DisRecommend = React.lazy(_ => import("@/pages/discover/cpns/recommend"));
const DisRanking = React.lazy(_ => import("@/pages/discover/cpns/ranking"));
const DisSongs = React.lazy(_ => import("@/pages/discover/cpns/songs"));
const DisDjradio = React.lazy(_ => import("@/pages/discover/cpns/djradio"));
const DisArtist = React.lazy(_ => import("@/pages/discover/cpns/artist"));
const DisAlbum = React.lazy(_ => import("@/pages/discover/cpns/album"));
const DisPlayer = React.lazy(_ => import("@/pages/player"));
const MyFriend = React.lazy(_ => import("@/pages/friend"));



function SetRoutes() {
  const routes = useRoutes([
    {
      path: "/",
      element: <Navigate to="/discover" />
    },
    {
      path: "/discover",
      element: <MyDiscover />,
      children: [
        {
          path: "/discover",
          element: <Navigate to="/discover/recommend" />
        },
        {
          path: "/discover/recommend",
          element: <DisRecommend />
        },
        {
          path: "/discover/ranking",
          element: <DisRanking />
        },
        {
          path: "/discover/songs",
          element: <DisSongs />
        },
        {
          path: "/discover/djradio",
          element: <DisDjradio />
        },
        {
          path: "/discover/artist",
          element: <DisArtist />
        },
        {
          path: "/discover/album",
          element: <DisAlbum />
        },
        {
          path: "/discover/player",
          element: <DisPlayer />
        }
      ]
    },
    {
      path: "/mine",
      element: <MyMine />
    },
    {
      path: "/friend",
      element: <MyFriend />
    }
  ]);
  
  return routes
}

export default SetRoutes;